<template>
  <div class="app-container">
    <!-- 根据路由meta.showHeader字段决定是否显示头部栏 -->
    <HeaderBar v-if="showHeader" />
    <main class="main-content">
      <router-view></router-view>
    </main>
  </div>
</template>

<script setup lang="ts">
import { ref, watch } from 'vue'
import { useRoute } from 'vue-router'
import HeaderBar from './components/HeaderBar.vue'

const route = useRoute()
const showHeader = ref(true)

// 监听路由变化，根据meta.showHeader字段更新头部栏显示状态
watch(
  () => route.meta,
  (newMeta) => {
    showHeader.value = newMeta.showHeader !== false
  },
  { immediate: true }
)
</script>

<style scoped>
.app-container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background-color: #f5f7fa;
}
</style>
